from typing import List


class Solution:
    def findMaxAverage(self, nums: List[int], k: int) -> float:
        flag = sum(nums[0:k])
        sums = sum(nums[0:k])
        for i in range(1, len(nums)-k+1):
            sums = sums+nums[i+k-1]-nums[i-1]
            flag = max(flag, sums)
        return flag/k


class Solution:
    def findMaxAverage(self, nums: List[int], k: int) -> float:
        flag = sum(nums[0:k])
        sums = sum(nums[0:k])
        for i in range(1, len(nums)-k+1):
            sums = sums+nums[i+k-1]-nums[i-1]
            flag = max(flag, sums)
        return flag/k


nums = [1,12,-5,-6,50,3]
k = 2
model = Solution()
print(model.findMaxAverage(nums, k))